package com.sgd.cli.pattern;

import java.util.ArrayList;

/**
 * <p>Title: 调用者（相当于遥控器）</p>
 * <p>Description: 作用是接受客户端的命令并执行</p>
 *
 * @author su.gd
 * @date 2023-11-22
 */
public class RemoteControl {
    private Command command;
    public static ArrayList<Command> list = new ArrayList<>();

    /**
     * 接受客户端命令
     * @param command
     */
    public void setCommand(Command command) {
        this.command = command;
    }

    // todo 存储历史记录
    public void storageHistory() {
        list.add(command);
    }

    // todo 撤销重做
    public void undo() {
        list.remove(command);
    }

    public void pressButton() {
        command.execute();
    }
}
